﻿Public Class CLSBanco
    Dim conexao As String = "Provider=microsoft.ace.oledb.12.0;data source=..\..\db\DBSCP.accdb"
    'Dim conexao As String = "Provider=microsoft.ace.oledb.12.0;data source=DBSCP.accdb"

    Public objcon As New OleDb.OleDbConnection(conexao)
    Private Sub abrir_banco()
        Try
            objcon.Open()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub
    Public Sub fechar_banco()
        If objcon.State = ConnectionState.Open Then
            objcon.Close()
        End If
    End Sub
    Public Sub executar_comando(ByVal sql As String)
        abrir_banco()
        Dim objcmd As New OleDb.OleDbCommand(sql, objcon)
        objcmd.ExecuteNonQuery()
        fechar_banco()
    End Sub
    Public Function Navegar(ByVal tabela As String) As DataTable
        Dim sql As String = "select * from " & tabela
        Dim objda As New OleDb.OleDbDataAdapter(sql, objcon)
        Dim objds As New DataSet
        objda.Fill(objds)
        Return objds.Tables(0)
    End Function





End Class
